Page({
  data: {
    imgUrls: [
      '/image/aa1.jpg',
      '/image/aa2.jpg',
      '/image/aa3.jpg'
    ],
    
	noticeIdx: 0,
    notices: [
      {
         "info": "欢迎各位朋友光临本店"
      },
      {
         "info": "老三传媒欢迎您！"
      },
      {
         "info": "主营：彩铃通讯，纹身，纹眉等业务。"
      }
    ],
    indicatorDots: false,
    autoplay: false,
    interval: 3000,
    duration: 800,
  },
  onLoad: function() {
    var me = this;
    var animation = wx.createAnimation( {
      duration: 400,
      timingFunction: 'ease-out',
    });
    me.animation = animation;
    wx.getSystemInfo( {
      success: function( res ) {
        me.setData( { windowWidth: res.windowWidth })
      }
    });

    //console.log( 'onLoad' );
    wx.request({
        url: 'http://nbkjsp1.nb.10v5.com:8081/WxApp/', //仅为示例，并非真实的接口地址
        data: {},
        header: {
            'content-type': 'application/json' // 默认值
        },
        success: function (res) {
            console.log(res.data.data);
            me.setData({
                pro:res.data.data.product,
                aBout: res.data.data.about,
                bAnner: res.data.data.banner.ad
            })
        }
    })

  },
  startNotice: function() {
    var me = this;
    var notices = me.data.notices || [];
    if( notices.length == 0 ) {
      return;
    }

    var animation = me.animation;
    //animation.translateY( -12 ).opacity( 0 ).step();
    animation.translateY( 0 ).opacity( 1 ).step( { duration: 0 });
    me.setData( { animationNotice: animation.export() });

    var noticeIdx = me.data.noticeIdx + 1;
    if( noticeIdx == notices.length ) {
      noticeIdx = 0;
    }

    // 更换数据
    setTimeout( function() {
      me.setData( {
        noticeIdx: noticeIdx
      });
    }, 400 );

    // 启动下一次动画
    setTimeout( function() {
      me.startNotice();
    }, 5000 );
  },
  onShow: function() {
    this.startNotice();

  },
    onShareAppMessage: function () {
    return {
      title: '老三传媒',
      desc: '专注于彩铃，纹身，纹眉。',
      path: "page/index",
    }
  },
})